﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WordMaster
{
    public partial class PageSetupDistanceForm : Form
    {
        public PageSetupDistanceForm()
        {
            InitializeComponent();
        }

        public List<TaskInfo> Tasks = new List<TaskInfo>();

        //
        private void btnOK_Click(object sender, EventArgs e)
        {
            //
            if (!HasChecked())
            {
                MessageBox.Show(
                    "请至少选中一项", 
                    "温馨提示", 
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation, 
                    MessageBoxDefaultButton.Button1);
                return;
            }

            //
            if (chkHeaderDistance.Checked)
            {
                Tasks.Add(new TaskInfo(
                    TaskTypes.PageSetupHeaderDistance,
                    "页眉距离",
                    "调整页眉距页面顶部的距离=" + nudHeaderDistence.Value.ToString() + "厘米",
                    new object[] { Convert.ToSingle(nudHeaderDistence.Value) }));
            }

            //
            if (chkFooterDistance.Checked)
            {
                Tasks.Add(new TaskInfo(
                    TaskTypes.PageSetupFooterDistance,
                    "页脚距离",
                    "调整页脚距页面底部的距离=" + nudFooterDistance.Value.ToString() + "厘米",
                    new object[] { Convert.ToSingle(nudFooterDistance.Value) }));
            }

            //
            DialogResult = DialogResult.OK;
            Close();
        }

        // 是否有选中的项
        public bool HasChecked()
        {
            return chkHeaderDistance.Checked || chkFooterDistance.Checked;
        }
    }
}
